<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="0">
    <title>预约体检系统管理后台</title>
    <link rel="stylesheet" href="./static/css/style.css">
    <link rel="stylesheet" href="./static/css/styleoneadd.css">
    <link rel="stylesheet" href="./static/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="./static/plugins/bootstrap-3.3.7/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="./static/plugins/bootstrap-3.3.7/css/bootstrap.min.css">
    <style>
       body{
           margin:0; padding:0;
           background-image: url("./static/images/login-bg.png");
           width: 100%;
           height: 100%;
        }
        .layui-center{
            width: 500px;
            background-color: #ffffff;
            text-align: center;
            padding: 10px;
            display: inline-block;
            z-index: 9999999;
            box-shadow: 1px 1px 6px 0px rgba(0,0,0,0.5);
        }
        .layui-rows-line{
            background-color: #77C8E4;
            position: absolute;
            left: 50%;
            top: 30%;
            margin-left: -50%;
            /*margin-top: 200px;*/
            width: 100%;
            padding: 30px 0px;
            text-align: center;
            opacity: 0.8;
        }
        .login-title{
            margin-bottom: 2rem;
        }
       .layui-name{
           text-align: right !important;
           width: 100px;
       }
        .layui-padd-left1{
            padding-left:6rem;
        }
        .login-btns{
            background-color: #61BDDF;
            color: #ffffff;
            width: 155px;
            height: 35px;
            line-height: 35px;
            border-radius: 5px;
            border: none;
        }
        .layui-rows-line .layui-input-inline input{

            border-radius: 5px;
            height: 30px;
            line-height: 30px;
        }
    </style>
</head>
<body>
<script src="./static/js/app/consts/consts.js"></script>
<script>
    // iframe的情况
    if (self != top) {
        top.location.href  = baseUrl + "/login.html";
    }
</script>
<div class="layui-row layui-rows-line">
    <div class="layui-center">
        <h1 class="login-title">预约体检系统管理后台</h1>
        <form class="layui-form" action="">
            <div class="layui-form-item layui-padd-left1">
                <label class="layui-form-label  layui-name">用户名：</label>
                <div class="layui-input-inline">
                    <input id="username" type="text" name="username" required  lay-verify="required"  autocomplete="off" class="form-control">
                </div>
            </div>
            <div class="layui-form-item layui-padd-left1">
                <label class="layui-form-label layui-name">密码：</label>
                <div class="layui-input-inline">
                    <input id="password" type="password" name="password" required  lay-verify="required"  autocomplete="off" class="form-control">
                </div>
            </div>
            <div class="layui-form-item ">
                <button id="loginBtn" type="button" class="login-btns" style="cursor: pointer;">登录</button>
            </div>
        </form>
    </div>
</div>

<script src="static/plugins/layui/layui.js"></script>
<script src="static/js/jquery.min.js"></script>
<script src="static/js/angular.js"></script>
<script>
    $(function () {
        $("#password").on("keyup", function (event) {
            if (event.keyCode == '13') {
                doLogin();
            }
        });

        $("#loginBtn").on("click", function () {
            doLogin();
        });

        function doLogin() {
            if ($("#username").val() && $("#password").val()) {
                $.ajax({
                    type: "POST",
                    url: baseUrl + "/doLogin",
                    data: {
                        "username": $("#username").val(),
                        "password": $("#password").val()
                    },
                    success: function (msg) {
//                        msg = {
//                            state:1,
//                            message:"true"
//                        }
                        if (msg && msg.state == 1) {
                            if (msg.message == "true") {
                                    document.location.href = baseUrl + adminBaseUrl;
                            } else {
                                document.location.href = baseUrl + normalBaseUrl;
                            }
                        } else {
                            layer.msg((msg && msg.message ? msg.message : "登录失败"));
                        }
                    },
                    error: function () {
                        layer.msg("登录失败");
                    }
                });
            } else {
                layer.msg("请输入用户名和密码");
            }
        }
    });
    layui.use(['layer'], function () {
    });
</script>
</body>
</html>